<template>
  <view>
    <view class="bulletinModule">
      <view class="title c1F1F1F f32 fontWeight">
        {{ info.title }}
      </view>
      <view class="time flex aitems">
        <image src="@/static/img5.png" mode=""></image>
        <view class="c525252 f28">
          {{ info.createTime }}
        </view>
      </view>
      <view class="content">
        <u-parse :content="info.content"></u-parse>
      </view>
    </view>
  </view>
</template>

<script>
import { bulletinInfo, updateParent } from "@/servers/servers.js";
import { HTTP_STATUS } from "@/servers/config.js";
import { loading, go } from "@/utils/wxAPI";
import { getToken } from "../../utils/storage";
import { handleLoopCallBack } from "../../utils/util";
export default {
  data() {
    return {
      options: {},
      info: {},
    };
  },
  async onLoad(options) {
    this.options = options;
    if (getToken()) {
      this.handleBulletinInfo();
      if (this.options.uid) {
        updateParent({
          id: this.options.uid,
        });
      }
    } else {
      handleLoopCallBack(async () => {
        this.handleBulletinInfo();
        if (this.options.uid) {
          updateParent({
            id: this.options.uid,
          });
        }
      });

      // #ifdef H5
      if (getEnv() == "H5") {
        uni.reLaunch({
          url: "/pages/login/login",
        });
      }
      // #endif
    }
  },
  methods: {
    async handleBulletinInfo() {
      loading();
      let { data } = await bulletinInfo({
        id: this.options.id,
      });
      if (data.code == HTTP_STATUS.RUSELT_SUCCESS) {
        let info = data.data;
        this.info = info;
      }
      uni.hideLoading();
    },
  },
  onPullDownRefresh() {
    this.handleBulletinPage();
  },
  onShareAppMessage: function (e) {
    return {
      title: "公告详情",
      path: `/pages/bulletin/detail?uid=${getGloBalData("userinfo").id}&id=${
        this.options.id ? this.options.id : ""
      }`,
    };
  },
};
</script>

<style scoped lang="scss">
.bulletinModule {
  margin: 30rpx 30rpx 0;

  .title {
  }

  .time {
    margin: 33rpx 0 0;

    image {
      width: 40rpx;
      height: 40rpx;
      margin: 0 8rpx 0 0;
    }
  }
  .content {
    margin: 50rpx 0 0;
  }
}
</style>
